import { defineStore } from "pinia"
import { computed, ref } from "vue"

export const useStoreTwo = defineStore('storeTwo', () => {
    // 定义的state
    const count2 = ref(0)
    const description2 = ref('这是componsition API 风格的一个storeOne')

    // 定义的getter，composition API 风格的getter是计算属性
    const getCountDescription2 = computed(() => {
        return `${description2.value}，其中一个值为${count2.value}`
    })
    // 定义的action
    const actionTest2 = () => {
        count2.value++
    }

    // pinia中所有定义的属性都要导出
    return {
        count2,
        description2,
        getCountDescription2,
        actionTest2
    }
})